package edu.cuit.svsp.config;


import edu.cuit.svsp.entity.Video;
import edu.cuit.svsp.service.VideoService;
import edu.cuit.svsp.util.OssUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;
import java.util.List;

@Configuration
@EnableScheduling    //开启定时任务
public class VideoTask {
	@Resource
	private VideoService videoService;

	@Resource
	private OssUtil greenVideoUtil;
    //指定策略 每隔30秒执行一次
//	@Scheduled(cron="0/30 * * * * ?")
//	public void task() {
//		List<Video> videoList = videoService.findByStateCommit();
//		videoList.forEach(video -> {
//			String reason = "违规";
//			if((reason = greenVideoUtil.checkState(video.getTaskId())) != null){
//				video.setReason(reason);
//				videoService.updateState(video);
//			}
//		});
//	}
}